/*
 * @Author: EyeSklear 1814580085@qq.com
 * @Date: 2024-03-04 20:27:13
 * @LastEditors: EyeSklear 1814580085@qq.com
 * @LastEditTime: 2024-04-26 16:08:41
 * @FilePath: \Scene_Back\src\path-list\path-list.controller.ts
 * @Description:
 *
 * Copyright (c) 2024 by EyeSklear , All Rights Reserved.
 */
/*
 * @Author: EyeSklear 1814580085@qq.com
 * @Date: 2024-03-04 20:27:13
 * @LastEditors: EyeSklear 1814580085@qq.com
 * @LastEditTime: 2024-03-08 10:18:55
 * @FilePath: \Scene_Back\src\path-list\path-list.controller.ts
 * @Description:
 *
 * Copyright (c) 2024 by EyeSklear , All Rights Reserved.
 */
import {
  Controller,
  Get,
  Res,
  Post,
  Body,
  Req,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { PathListService } from './path-list.service';
import { CreatePathListDto } from './dto/create-path-list.dto';
import { UpdatePathListDto } from './dto/update-path-list.dto';
import { Request } from 'express';

@Controller('path-list')
export class PathListController {
  constructor(private readonly pathListService: PathListService) {}

  @Post('createPath')
  async create(
    @Body() createPathListDto: CreatePathListDto,
    @Req() request: Request,
  ) {
    const user = request.user;
    createPathListDto.creator = (user as any).email;
    const uuid = await this.pathListService.create(createPathListDto);
    return uuid;
  }

  @Get()
  findAll() {
    return this.pathListService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.pathListService.findOne(id);
  }

  @Patch('updatePathList/:id')
  update(
    @Param('id') id: string,
    @Body() updatePathListDto: UpdatePathListDto,
  ) {
    return this.pathListService.update(id, updatePathListDto);
  }

  @Delete('deletePath/:id')
  remove(@Param('id') id: string) {
    return this.pathListService.remove(id);
  }
}
